package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.LeaveApplicationsMapper;
import com.ruoyi.system.domain.LeaveApplications;
import com.ruoyi.system.service.ILeaveApplicationsService;
import com.ruoyi.common.core.domain.entity.SysUser;
/**
 * 请假申请Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-30
 */
@Service
public class LeaveApplicationsServiceImpl implements ILeaveApplicationsService
{
    @Autowired
    private LeaveApplicationsMapper leaveApplicationsMapper;

    /**
     * 查询请假申请
     *
     * @param id 请假申请主键
     * @return 请假申请
     */
    @Override
    public LeaveApplications selectLeaveApplicationsById(Long id)
    {
        return leaveApplicationsMapper.selectLeaveApplicationsById(id);
    }

    /**
     * 查询请假申请列表
     *
     * @param leaveApplications 请假申请
     * @return 请假申请
     */
    @Override
    public List<LeaveApplications> selectLeaveApplicationsList(LeaveApplications leaveApplications)
    {
        return leaveApplicationsMapper.selectLeaveApplicationsList(leaveApplications);
    }

    /**
     * 新增请假申请
     *
     * @param leaveApplications 请假申请
     * @return 结果
     */
    @Override
    public int insertLeaveApplications(LeaveApplications leaveApplications)
    {
        return leaveApplicationsMapper.insertLeaveApplications(leaveApplications);
    }

    /**
     * 修改请假申请
     *
     * @param leaveApplications 请假申请
     * @return 结果
     */
    @Override
    public int updateLeaveApplications(LeaveApplications leaveApplications)
    {
        return leaveApplicationsMapper.updateLeaveApplications(leaveApplications);
    }

    /**
     * 批量删除请假申请
     *
     * @param ids 需要删除的请假申请主键
     * @return 结果
     */
    @Override
    public int deleteLeaveApplicationsByIds(Long[] ids)
    {
        return leaveApplicationsMapper.deleteLeaveApplicationsByIds(ids);
    }

    /**
     * 删除请假申请信息
     *
     * @param id 请假申请主键
     * @return 结果
     */
    @Override
    public int deleteLeaveApplicationsById(Long id)
    {
        return leaveApplicationsMapper.deleteLeaveApplicationsById(id);
    }



    @Override
    public List<SysUser> selectDeptManagersByUserId(Long userId) {
        return leaveApplicationsMapper.selectDeptManagersByUserId(userId, 102L); // 确保角色 ID 正确
    }
    @Override
    public List<LeaveApplications> selectLeaveListByRole(LeaveApplications leaveApplications, Long currentUserId) {
        return leaveApplicationsMapper.selectLeaveListByRole(leaveApplications, currentUserId);
    }

    // 请假天数
    @Override
    public int selectMonthlyLeaveDays(Long userId) {
        return leaveApplicationsMapper.selectMonthlyLeaveDays(userId);
    }
}
